unit MMenu;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, PDJButton, StdCtrls, INIFiles, Spin, Basic, ExtCtrls;

type
  TForm2 = class(TForm)
    PDJButton1: TPDJButton;
    PDJButton4: TPDJButton;
    PDJButton5: TPDJButton;
    Edit1: TEdit;
    PDJButton2: TPDJButton;
    Label2: TLabel;
    SpinEdit1: TSpinEdit;
    Label3: TLabel;
    portControl: TSpinEdit;
    Image1: TImage;
    procedure PDJButton5Click(Sender: TObject);
    procedure PDJButton1Click(Sender: TObject);
    procedure PDJButton2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure PDJButton4Click(Sender: TObject);
    procedure Label1DblClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

uses Unit1, CrGame, PlForm;

{$R *.dfm}

procedure TForm2.PDJButton5Click(Sender: TObject);
begin
  Close;
end;

procedure TForm2.PDJButton1Click(Sender: TObject);
begin
  If NazwaPostaci<>'' then
    Form3.ShowModal;
end;

procedure TForm2.PDJButton2Click(Sender: TObject);
begin
  Form4.ShowModal;
end;

procedure TForm2.FormCreate(Sender: TObject);
var I:TIniFile;
    C:Integer;
begin
  I:=TINIFile.Create(ExtractFilePath(Application.ExeName)+'/data/players/players.ini');
  NazwaPostaci:=I.ReadString('Player','CurrentPlayer','');
  Label2.Caption:='Current Player: '+NazwaPostaci;
  AppExeName:=Application.ExeName;
end;

procedure TForm2.PDJButton4Click(Sender: TObject);
begin
  If NazwaPostaci<>'' then
  begin
    Form1.Edit1.Text:=Edit1.Text;
    Form1.Button2Click(Sender);
    Hide;
    Form1.Show;
    Multiplayer.Connect(0,Edit1.Text,Form2.portControl.Value);
    Form1.Button4.Hide;
    Form1.Edit1.Hide;
  end;
end;

procedure TForm2.Label1DblClick(Sender: TObject);
begin
  SpinEdit1.Enabled:=True;
end;

end.
